package com.randi.common.enums;

/**
 * @author ziye
 */
public enum ResultCode {

    /**
     * 成功【业务】
     */
    SUCCESS(1000, "success"),
    BUSINESS_INPUT_SUCCESS(1001, "添加成功"),
    BUSINESS_EDITOR_SUCCESS(1002, "修改成功"),
    BUSINESS_DELETE_SUCCESS(1003, "删除成功"),
    BUSINESS_IMPORT_SUCCESS(1004, "导入成功"),
    BUSINESS_UPLOAD_SUCCESS(1600, "上传成功"),
    API_TEST_SUCCESS(1999, "接口连接正常"),

    /**
     * 失败【业务】
     */
    BUSINESS_EXCEPTION(2000, "操作异常"),
    BUSINESS_ERROR_DETAIL(2001, "操作失败, {}"),
    BUSINESS_INSERT_ERROR(2010, "添加失败"),
    BUSINESS_INSERT_ERROR_DETAIL(2011, "添加失败, {}"),
    BUSINESS_EDITOR_ERROR(2020, "修改失败"),
    BUSINESS_EDITOR_ERROR_DETAIL(2021, "修改失败, {}"),
    BUSINESS_EDITOR_ERROR_AVATAR(2022, "更新头像失败"),
    BUSINESS_EDITOR_ERROR_DISABLE(2029, "修改失败，不允许操作"),
    BUSINESS_DELETE_ERROR(2030, "删除失败"),
    BUSINESS_IMPORT_ERROR(2040, "导入失败"),
    BUSINESS_EXPORT_ERROR(2050, "导出数据错误，请联系管理员"),

    /**
     * 菜单
     */
    BUSINESS_INSERT_ERROR_SUP_MENU_NOT_EXIST(2201, "添加失败，上级菜单不存在"),
    BUSINESS_INSERT_ERROR_SUP_MENU_DISABLE(2202, "添加失败，上级菜单已停用"),

    /**
     * 授权
     */
    BUSINESS_ROLE_AUTH_SUCCESS(1300, "授权更新成功"),
    BUSINESS_ROLE_AUTH_CANCEL_SUCCESS(1350, "取消授权成功"),
    BUSINESS_ROLE_AUTH_ERROR(2300, "授权更新失败"),
    BUSINESS_ROLE_AUTH_ERROR_ADMIN(2301, "授权更新失败, 管理员不允许授权相关操作"),
    BUSINESS_ROLE_AUTH_ERROR_NO_USER(2302, "授权更新失败, 不存在可授权用户"),
    BUSINESS_ROLE_AUTH_CANCEL_ERROR(2350, "取消授权失败"),
    BUSINESS_ROLE_AUTH_CANCEL_ERROR_ADMIN(2351, "取消授权失败, 管理员不允许授权相关操作"),
    BUSINESS_ROLE_AUTH_CANCEL_ERROR_NO_USER(2352, "取消授权失败, 不存在可取消授权用户"),


    /**
     * 登录
     */
    LOGIN_SUCCESS(1010, "登录成功"),
    LOGIN_OUT_SUCCESS(1011, "退出登录成功"),
    LOGIN_EXCEPTION(2050, "登录异常"),
    LOGIN_TYPE_NOT_EXIST(2051, "登录方式不存在, 请更换其他方式登录"),
    LOGIN_USER_NOT_EXIST(2052, "用户不存在"),
    LOGIN_PASSWORD_ERROR(2053, "密码输入错误"),
    LOGIN_PASSWORD_ERROR_FORMAT(2054, "密码输入错误{}次"),
    LOGIN_CODE_ERROR(2055, "验证码错误"),
    LOGIN_CODE_TIMEOUT(2056, "验证码过期"),
    LOGIN_USER_DISABLE(2057, "用户停用"),
    LOGIN_PASSWORD_ERROR_FAST(2058, "密码输入错误过多，请稍后重试"),
    LOGIN_PASSWORD_ERROR_FAST_FORMAT(2059, "密码输入错误{}次，帐户锁定{}分钟"),

    /**
     * 当前用户
     */
    CURRENT_UPDATE_PASSWORD_SUCCESS(1060, "密码修改成功"),
    CURRENT_UPDATE_PASSWORD_SUCCESS_AGAIN_LOGIN(4100, "修改成功, 请重新登录！"),
    CURRENT_UPDATE_PASSWORD_ERROR(2060, "密码修改失败"),
    CURRENT_UPDATE_PASSWORD_ERROR_ALIKE(2062, "密码修改失败, 输入原密码和新密码一致"),
    CURRENT_UPDATE_PASSWORD_ERROR_NOT_CONFIRM(2061, "密码修改失败, 输入新密码和确认密码不一致"),
    CURRENT_UPDATE_PASSWORD_ERROR_NOT_MATCH(2062, "密码修改失败, 密码输入错误"),
    CURRENT_UPDATE_PASSWORD_ERROR_LOCKING(2063, "密码修改错误过多, 请稍后重试"),

    /**
     * Secret
     */
    SECRET_SALT_ERROR(2120, "加密盐错误，请稍后重试"),
    SECRET_SALT_EXPIRE(2121, "加密盐失效"),
    SECRET_DECRYPT_EXCEPTION(2130, "解密异常"),
    SECRET_DECRYPT_ERROR(2131, "解密失败"),
    SECRET_ENCRYPT_EXCEPTION(2132, "加密异常"),
    SECRET_ENCRYPT_ERROR(2133, "加密失败"),

    /**
     * 文件
     */
    FILE_RENAME_SUCCESS(1601, "文件重命名成功"),
    FILE_MOVE_SUCCESS(1602, "文件移动成功"),
    FILE_REMOVE_SUCCESS(1603, "文件删除成功"),
    FILE_DOWNLOAD_SUCCESS(1604, "文件下载成功"),
    FILE_DOWNLOAD_CREATE_SUCCESS(1605, "文件下载任务创建成功"),
    FILE_UPLOAD_SUCCESS(1606, "文件上传成功"),

    FILE_UPLOAD_FAIL(2200, "上传失败"),
    FILE_PATH_ERROR(2201, "文件路径异常"),
    FILE_PATH_NOT_EXIST(2202, "文件路径不存在"),
    FILE_NAME_NULL(2203, "文件名不能为空"),
    FILE_NOT_EXIST(2600, "文件不存在"),
    FILE_RENAME_FAIL(2610, "文件重命名失败"),
    FILE_RENAME_FAIL_NOT_EXIST(2611, "文件重命名失败, 文件不存在"),
    FILE_RENAME_FAIL_NAME_EXIST(2612, "文件重命名失败, 名称已存在"),
    FILE_MOVE_FAIL(2620, "文件移动失败"),
    FILE_MOVE_FAIL_NOT_EXIST(2621, "文件移动失败, 文件不存在"),
    FILE_MOVE_FAIL_PATH_EXIST(2622, "文件移动失败, 目标路径已存在"),
    FILE_REMOVE_FAIL(2630, "文件删除失败"),
    FILE_REMOVE_FAIL_NOT_EXIST(2631, "文件删除失败, 文件不存在"),
    FILE_DOWNLOAD_FAIL(2640, "文件下载失败"),
    FILE_DOWNLOAD_FAIL_NOT_EXIST(2641, "文件下载失败, 文件不存在"),
    FILE_DOWNLOAD_FAIL_EXPIRED(2642, "文件下载失败, 下载已过期"),
    FILE_DOWNLOAD_FAIL_CREATE(2643, "文件下载失败, 创建下载任务失败"),
    FILE_UPLOAD_FAIL_NAME_LONG(2651, "文件上传失败，文件名过长"),
    FILE_UPLOAD_FAIL_SIZE(2652, "文件上传失败，文件大小超过限制"),
    FILE_UPLOAD_FAIL_TYPE(2653, "文件上传失败，文件类型不匹配"),
    FILE_UPLOAD_FAIL_NOT_EXIST(2654, "文件上传失败，文件不存在"),
    FILE_UPLOAD_FAIL_NOT_SUPPORT(2655, "文件上传失败，文件类型不支持"),
    FILE_UPLOAD_FAIL_NOT_ALLOW(2656, "文件上传失败，文件类型不允许"),
    FILE_UPLOAD_SLICE_FAIL(2660, "文件分片上传失败"),
    FILE_UPLOAD_SLICE_FAIL_EXIST(2661, "文件上传失败, 文件已存在"),
    FILE_UPLOAD_SLICE_FAIL_SIZE(2662, "文件上传失败, 文件大小不匹配"),
    FILE_UPLOAD_SLICE_FAIL_NOT_ALLOW(2663, "文件上传失败, 文件类型不允许"),
    FILE_UPLOAD_SLICE_FAIL_NOT_SUPPORT(2664, "文件上传失败, 文件类型不支持"),
    FILE_UPLOAD_SLICE_FAIL_MERGE(2670, "文件上传失败，分片合并失败"),
    FILE_UPLOAD_SLICE_FAIL_MERGE_LACK(2671, "文件上传失败, 分片缺失"),
    FILE_UPLOAD_SLICE_FAIL_MERGE_TASK_NOT_EXIST(2672, "文件上传失败, 合并任务已失效"),

    /**
     * 请求参数
     */
    OPERATION_TOO_FAST(3000, "操作过于频繁，请稍后重试"),
    HEADER_PARAM_ERROR(3001, "请求头参数错误"),
    PARAM_ERROR(3002, "参数错误"),
    PARAM_ERROR_NULL(3003, "参数为空"),
    PARAM_ERROR_DUPLICATE(3003, "参数错误，唯一值已存在"),
    PARAM_ERROR_DUPLICATE_FORMAT(3003, "参数错误，{}已存在"),
    PARAM_ERROR_MISSING(3003, "参数缺失"),
    PARAM_TYPE_ERROR(3004, "参数类型错误"),
    PARAM_RANGE_ERROR(3005, "参数范围错误"),
    PARAM_LENGTH_ERROR(3006, "参数长度错误"),
    PARAM_REGEX_ERROR(3007, "参数正则校验错误"),
    PARAM_NOT_BLANK_ERROR(3008, "参数不能为空"),
    REQUEST_METHOD_ERROR(3010, "请求方法不支持"),
    /**
     * 认证
     */
    NOT_LOGIN(4000, "请先登录"),
    LOGIN_EXPIRED(4001, "登录已过期，请重新登录"),
    TOKEN_EXPIRED(4002, "令牌失效"),
    AUTH_FAILED(4003, "认证失败，无法访问系统资源"),
    NO_PERMISSION(4004, "没有权限，请联系管理员授权"),

    /**
     * 系统
     */
    SYSTEM_ERROR(5000, "系统异常, 请联系管理员"),
    SQL_ERROR(5001, "SQL异常, 请联系管理员"),
    DRUID_CONNECTION_ERROR(5001, "数据库连接异常, 请联系管理员"),
    REDIS_CONNECTION_ERROR(5002, "Redis连接异常, 请联系管理员"),
    SYSTEM_DEV(4005, "功能正在研发中，请耐心等待");

    private final Integer status;

    private final String message;

    ResultCode(Integer status, String message) {
        this.status = status;
        this.message = message;
    }

    public Integer status() {
        return this.status;
    }

    public String message() {
        return this.message;
    }

}
